package com.tanhua.admin.controller;


import com.tanhua.admin.service.DashboardService;

import com.tanhua.model.vo.DashboardVo;
import com.tanhua.model.vo.Summary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;


    /*
     *  概要统计信息 /
     *    请求方式和请求链接 :  GET  /summary
     *    请求参数:
     *    返回值: AnalysisVo
     * */
    @GetMapping("/summary")
    public ResponseEntity summary() throws ParseException {

        Summary vo = dashboardService.summary();

        return ResponseEntity.ok(vo);
    }

    /**
     * GET
     * /dashboard/users
     * 新增、活跃用户、次日留存率
     * sd	 开始时间
     * ed   结束时间
     * type 101 新增 102 活跃用户 103 次日留存率
     */
    @GetMapping("/users")
    public ResponseEntity users(String sd, String ed, Integer type) {
        DashboardVo vo = dashboardService.users (sd, ed, type);
        return ResponseEntity.ok (vo);
    }

}
